#INCLUDE "PROTHEUS.CH"
#INCLUDE "APWEBEX.CH"
/*/{Protheus.doc} DTRWEB04

@descricao EXECUCAO DA GERACAO DE OS

@author Peterson Scherwinski

@since 15/07/2014

/*/
User Function DTRWEB04
	Local cHtml	:= ""
	local oObj
	local cPagina	:= "DTRHTM04"//pagina a ser apresentada

	Web Extended Init cHtml// START "init"

		//controle de acesso / timeout
		if type("HTTPSESSION->USERLOGIN") <> "A"
			HTTPSESSION->ALERT	:= "Necessario efetuar o login."
			RETURN( RedirPage('/U_DTRWEB01.apw'))
		endif

		HTTPSESSION->ALERT		:= ""
		HTTPSESSION->SUCESSO		:= .T.
		
		//VALIDAR E SALVAR AS AGENDAS
		oObj := WSDTRWEBSR():New()
		
		oObj:CTOKEN 		:= "DATAROUTEWEB"
		oObj:OWSJOBUPDT := DTRWEBSR_DADOSAGENDA():New()
		
		oObj:OWSJOBUPDT:cRESOURCE := HTTPSESSION->SCHEDULE[1]
		oObj:OWSJOBUPDT:cDATESCHE := HTTPPOST->data
		oObj:OWSJOBUPDT:cPROJCODE := HTTPPOST->projeto
		oObj:OWSJOBUPDT:cPROJTASK := HTTPPOST->tarefa
		oObj:OWSJOBUPDT:cTIMESTAR := HTTPPOST->inicio
		oObj:OWSJOBUPDT:cTIMEEND  := HTTPPOST->fim
		oObj:OWSJOBUPDT:cTIMEDESC := HTTPPOST->outros
		oObj:OWSJOBUPDT:cDESCRIPT := FwNoAccent(HTTPPOST->detalhe)
		oObj:OWSJOBUPDT:nVLRALMO  := val(strTran(strTran(HTTPPOST->almoco,".",""),",","."))
		oObj:OWSJOBUPDT:nVLRDESP  := val(strTran(strTran(HTTPPOST->km,".",""),",","."))
		oObj:OWSJOBUPDT:cOBSDESP  := FwNoAccent(HTTPPOST->obsdesp)
		oObj:OWSJOBUPDT:nAGERECNO := HTTPSESSION->SCHEDULE[14]
		
		if !oObj:PUTJOB()
			HTTPSESSION->ALERT	:= PWSGetWSError()
			HTTPSESSION->SUCESSO		:= .F.
		else
			HTTPSESSION->ALERT := oObj:cPUTJOBRESULT
		endif

		//mantem os dados postado pelo usuario
		HTTPSESSION->SCHEDULE[2]	:= HTTPPOST->data
		HTTPSESSION->SCHEDULE[3]	:= HTTPPOST->projeto
		HTTPSESSION->SCHEDULE[4]	:= HTTPPOST->tarefa
		HTTPSESSION->SCHEDULE[5]	:= HTTPPOST->inicio
		HTTPSESSION->SCHEDULE[6]	:= HTTPPOST->fim
		HTTPSESSION->SCHEDULE[8]	:= FwNoAccent(HTTPPOST->detalhe)
		HTTPSESSION->SCHEDULE[9]	:= HTTPPOST->almoco
		HTTPSESSION->SCHEDULE[10]:= HTTPPOST->km
		HTTPSESSION->SCHEDULE[11]:= FwNoAccent(HTTPPOST->obsdesp)
		HTTPSESSION->SCHEDULE[12]:= HTTPPOST->outros
		execInPage(cPagina)
	
	Web Extended End

return(cHtml)
